/*
 * Output.java
 *
 * Created on June 26, 2006, 12:51 PM
 *
 * To change this template, choose Tools | Template Manager
 * and open the template in the editor.
 */

package libjdc.dc.log;

import hubsniffer.Settings;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.PrintStream;


/**
 *
 * @author root
 */
public class Log {
    
    public static PrintStream out = getOutPutStream();
    
    public static PrintStream err = getErrOutPutStream();
    
    public static void setOutPutStream(PrintStream out){
        Log.out = out;
    }
    public static void setErrOutPutStream(PrintStream err){
        Log.err = err;
    }
    
    private static PrintStream getErrOutPutStream() {
        try {
            return (err==null)? err = new PrintStream(new File(Settings.getInstance().getLOG_PATH()+File.separatorChar+"sniffer_err.log")) : err ;
        } catch (FileNotFoundException ex) {
            ex.printStackTrace(Log.err);
            return err = System.err;
        }
    }

    private static PrintStream getOutPutStream() {
        try {
            return (out==null)? out = new PrintStream(new File(Settings.getInstance().getLOG_PATH()+File.separatorChar+"sniffer.log")) : out ;
        } catch (FileNotFoundException ex) {
            ex.printStackTrace(Log.err);
            return out = System.out;
        }
    }
}